#ifndef __WINDOWSDEVICE_INCLUDED
#define __WINDOWSDEVICE_INCLUDED

namespace Audio
{
	namespace WindowsPlatform
	{
		class XAudio2VoiceCallback : public IXAudio2VoiceCallback
		{
		public:
			XAudio2VoiceCallback(WindowsAudioDevice* d) : device(d) {}
			void __stdcall OnStreamEnd();    
			void __stdcall OnVoiceProcessingPassEnd();
			void __stdcall OnVoiceProcessingPassStart(UINT32 SamplesRequired);
			void __stdcall OnBufferEnd(void * pBufferContext);
			void __stdcall OnBufferStart(void * pBufferContext);
			void __stdcall OnLoopEnd(void * pBufferContext);
			void __stdcall OnVoiceError(void * pBufferContext, HRESULT Error);

		private:
			WindowsAudioDevice* device;
		};		
		

		class WindowsAudioDevice : public IAudioDevice
		{
		public:
			WindowsAudioDevice();
			~WindowsAudioDevice();
			
			void Init();
			void Destroy();
			IVoice*			CreateVoice(void* info, UINT32 infoSize);
			void			DestroyVoice(IVoice*& voice);
			
			void SetDeviceCallback(IAudioDeviceCallBack* callback);
			IAudioDeviceCallBack* GetDeviceCallback();

		private:
			IXAudio2*  xaudio2;
			IXAudio2MasteringVoice* masteringVoice;
			XAudio2VoiceCallback*	xaudio2Callback;
			IAudioDeviceCallBack*	audioDeviceCallback;
		};
	}
}
#endif